/*
 * @Author: your name
 * @Date: 2021-04-01 10:45:32
 * @LastEditTime: 2021-04-16 11:18:03
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \web\node\route\index.js
 */
import express from "express"
import Sowing from "../models/Sowing"

const router = express.Router({})


/***************  后端界面的访问路由  *****************/
router.get("/back",(req,res,next)=>{
    res.render("back/index.html")
})


/***************  前端界面的访问路由  *****************/
router.get("/",(req,res,next)=>{
    res.redirect("/web")
})

router.get("/web",(req,res,next)=>{
    res.render("web/index.html")
})


router.get("/web/res",(req,res,next)=>{
    //查询数据，传入前端界面
    Sowing.find({}, "_id image_title image_url  image_link",(err, docs) => {
        if (err) {
          return next(err);
        }
        //追加一个字段
        let tag = ["one","two","three","four"];
        for(let i = 0;i < tag.length; i++){
            let doc = docs[i];
            doc["image_tag"] = tag[i]; 
        }

        res.render("web/resources.html", {docs})
    });

    
    
})

router.get("/web/res_c",(req,res,next)=>{
    res.render("web/resources_content.html")
})
export default router 